using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Beta_fundies_controls_publicadmin_PublicAdmin : Controls.DataManagerQuoteControl
{
    protected override void ItemChanged()
    {
        
    }

    protected override void UserLoggedIn(object sender, EventArgs e)
    {
        RefreshUser();
    }

    protected override void UserLoggedOut(object sender, EventArgs e)
    {
        RefreshUser();
    }

    private void RefreshUser()
    {
        DAL.User user = Managers.UserLoginManager.CurrentUser;
        if (user != null)
        {
            if (user.TotalPosts > Constants.PublicAdminSettings.MinimumRequiredPosts)
            {
                mviewUser.SetActiveView(viewAuthenticated);
            }
            else
            {
                mviewUser.SetActiveView(viewNotEnoughPosts);
            }
        }
        else
        {
            mviewUser.SetActiveView(viewLogin);
        }

        lblMinPosts1.Text = Constants.PublicAdminSettings.MinimumRequiredPosts.ToString();
        lblMinPosts2.Text = lblMinPosts1.Text;
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            RefreshUser();
        }
        Page.Title = "Public Admin";
    }
    protected void btnLogin_Click(object sender, EventArgs e)
    {
        DAL.User user = Managers.UserLoginManager.Login(txtUsername.Text, txtPassword.Text);
        if (user == null)
        {
            lblBadLogin.Visible = true;
        }
    }
}
